package com.share.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public SecurityInterceptor securityInterceptor(){
        return new SecurityInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(securityInterceptor()).addPathPatterns("/api/**")
                // Ant 路径模式不支持使用管道符号 |
                .excludePathPatterns("/api/user/login/*", "/api/user/register")
                .excludePathPatterns("/api/code/*")
                .excludePathPatterns("/api/file/*");
    }
}
